Note: This tutorial assumes you have completed previous tutorial siemens_cp1616/Tutorials/CP1616 in IO Device mode - User Node.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

CP1616 in IO Device mode - Runtime

Description: This tutorial teaches you how to run the wrapper and check the results

Keywords: SIEMENS, CP1616, PROFINET, IO Device, Runtime

Tutorial Level: INTERMEDIATE

Next Tutorial: siemens_cp1616/Tutorials/CP1616 in IO Device mode - Alarms

This tutorial teaches you how to run IO Device wrapper in comination with User Node, monitor and check the results. We recommend using additional computer connected to second PN port of PLC for easier monitoring and testing of PROFINET communication.

Run the launch file

If you have completed all configuration steps as describer in previous tutorials it is time to run existing launch file:

roslaunch siemens_cp1616_io_device_tutorial siemens_cp1616_io_device_tutorial.launch

If initialization succeded, you should notice red error indicators on both PLC and CP1616 turn off and get the following terminal output:

[ INFO]: CP1616 Configuration: Number of modules: 8
[ INFO]: Module: slot 1 sub 1 mod_id 19 sub_id 10001
[ INFO]: Module: slot 2 sub 1 mod_id 22 sub_id 1
[ INFO]: Module: slot 3 sub 1 mod_id 21 sub_id 1
[ INFO]: Module: slot 4 sub 1 mod_id 25 sub_id 1
[ INFO]: Module: slot 5 sub 1 mod_id 24 sub_id 1
[ INFO]: Module: slot 6 sub 1 mod_id 3d sub_id 1
[ INFO]: Module: slot 7 sub 1 mod_id 3c sub_id 1
[ INFO]: Module: slot 8 sub 1 mod_id 20 sub_id 1
[ INFO]: Openning CP1616 in IO_device mode: done
[ INFO]: Starting operation: done
[ INFO]: Setting device state to PNIO_DEVSTAT_OK: done
[ INFO]: Waiting for callbacks...
[ INFO]: IO Controller found: plcxb1d0ed IP 192.168.0.20
[ INFO]: New AR from IO controller established
[ INFO]: End of CP parametrization
[ INFO]: IO Device ready, communication started

NOTE: If initialization fails and return errors, please check if yaml config file meets the hardware configuration (addresses, sizes). If nevertheless errors still occurs please refer to original siemens cp1616 documentation.

Check webserver

If you have configured webserver in TIA Portal project, you can connect to CP1616 LAN Port and using configured Ethernet address, monitor CP state. If initialization succedded, CP1616 should report "Data exchange".

IO_device_webserver.jpg

Monitor topics

First use rostopic list command line tool to get the list of all active topics:

$ rostopic list

For this tutorial example, rostopic list should return:

/plc_bidirect_input_topic
/plc_bidirect_output_topic
/plc_input_byte_array_topic
/plc_input_byte_topic
/plc_input_real_topic
/plc_output_byte_array_topic
/plc_output_byte_topic
/plc_output_real_topic
/rosout
/rosout_agg

With default configuration, CP buffers are updated and synchronized with data on topics every 10ms. Using rostopic hz command line tool check if "cp_output" topics are updated regularly.

$ rostopic hz /plc_output_byte_topic

For this tutorial example, rostopic hz should return similar results:

average rate: 100.028
        min: 0.009s max: 0.010s std dev: 0.00047s window: 99
average rate: 99.998
        min: 0.009s max: 0.011s std dev: 0.00047s window: 199
average rate: 99.991
        min: 0.009s max: 0.011s std dev: 0.00047s window: 299

Average rate of cp_input topics in this example is approximately 2, since our tutorial node publishes data every 0.5 second. But synchronization with CP buffers still happens every 10ms.

Use Watch and Force tables

Using separate computers allows you to monitor and force values while running CP1616 application on the Linux side. To monitor data transmitted from CP1616 into PLC, you can use TIA Portal "Watch tables":

IO_Device_watch_tbl.jpg

To monitor and test opposite data direction you can use TIA Portal "Force tables".

IO_Device_force_tbl.jpg

For example after forcing "PLC_output_byte" to 10, you should see updated value on "cp_output_byte_topic":

$ rostopic echo /cp_output_byte_topic

Should provide following output:

layout:
  dim:
    -
      label: PLC_output_byte
      size: 1
      stride: 0
  data_offset: 0
data: [10]

Testing on a single computer

In case when only a single computer is available, use HMI or PLC Inputs/Outputs or other tools to monitor and change variables being transmitted over PROFINET.

Wiki: siemens_cp1616/Tutorials/CP1616 in IO Device mode - Runtime (last edited 2015-11-09 20:02:46 by FrantisekDurovsky)